#include<iostream>
using namespace std;
string S;
char c1;
char c2;
int main()
{
	int count = 0;
	int K;
	
	cin >> K >> S >> c1 >> c2;
	int n = S.size();
	for (int  j = 0;j<=n-K;j++)
	{
		if (S[j] == c1)
		{
			for (int i = K - 1+j; i < n; i++)
			{
				if (S[i] == c2)
				{
					count++;

				}



			}



		}
	
	
	
	
	}
	cout << count;







}